/*
 * @Author: yuki
 * @Date: 2025-10-25 10:13:38
 * @LastEditTime: 2025-10-26 10:50:06
 * @Description: app模块
 */
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';

import { AuthModule } from './auth/auth.module';
import config, { JwtConfigType, jwtConfig } from './config';
import { ShareModule } from './share/share.module';
import { UserModule } from './user/user.module';

@Module({
  imports: [
    // config除了load加载的配置还会合并.env中的配置
    ConfigModule.forRoot({
      isGlobal: true,
      load: config
    }),
    JwtModule.registerAsync({
      global: true,
      useFactory: (configService: JwtConfigType) => ({
        secret: configService.accessSecret,
        signOptions: {
          expiresIn: configService.accessExpiresIn
        }
      }),
      inject: [jwtConfig.KEY]
    }),
    AuthModule,
    ShareModule,
    UserModule
  ],
  controllers: [],
  providers: []
})
export class AppModule {}
